package javazuoye.four;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/06/27 10:46
 */
public class _8_1_2 {

    public static void main(String[] args) {
        int[] nums = new int[]{1,2,3,43,123,234,455,654};
        System.out.println(zheban(nums,234));
    }
    public static int zheban(int[] nums,int val){
        int start=0, end=nums.length-1;
        while (start<end){
            int zhong = (start+end)/2;
            if (nums[zhong]==val){
                return zhong;
            }
            if (nums[zhong]<val){
                start = zhong+1;
                continue;
            }
            if (nums[zhong]>val){
                end= zhong-1;
            }
        }
        return -1;
    }
}
